﻿using System;
using RestAPI;

namespace TopVisionVideoStream
{
    class VideoConferencManager
    {
        public static ConferencStatusType ConferencStatus
        {
            get { return Model_VideoConferenc.ConferencStatus; }
        }

        public static event VideoCallResultHandler VideoCallResult
        {
            add { Model_VideoConferenc.CallResultEvent += value; }
            remove { Model_VideoConferenc.CallResultEvent -= value; }
        }

        public static event VideoCallCancelResultHandler VideoCallCancelResult
        {
            add { Model_VideoConferenc.CallCancelResultEvent += value; }
            remove { Model_VideoConferenc.CallCancelResultEvent -= value; }
        }

        public static event VideoCallMeHandler VideoCallMe
        {
            add { Model_VideoConferenc.VideoCallMeEvent += value; }
            remove { Model_VideoConferenc.VideoCallMeEvent -= value; }
        }

        public static TakephotoCompleteHandler TakephotoComplete
        {
            get { return Model_VideoConferenc.TakephotoCompleteEvent; }
            set { Model_VideoConferenc.TakephotoCompleteEvent = value; }
        }

        public static event RemoteScreenTypeHandler RemoteScreenEvent
        {
            add { Model_VideoConferenc.RemoteScreenTypeEvent += value; }
            remove { Model_VideoConferenc.RemoteScreenTypeEvent -= value; }
        }

        public static event MessageInfoHandler MessageInfoEvent
        {
            add { Model_VideoConferenc.MessageInfoEvent += value; }
            remove { Model_VideoConferenc.MessageInfoEvent -= value; }
        }

        //public static VideoCallResultEvent AccepctCallResult
        //{
        //    get { return Model_VideoConferenc.AccepctCallResult; }
        //    set { Model_VideoConferenc.AccepctCallResult = value; }
        //}

        public static void Init()
        {
            Model_VideoConferenc.RegistEvent();
            Model_VideoConferenc.RegistCallEvent();
        }

        public static void VideoCall(string callID, CallType callType)
        {
            Model_VideoConferenc.VidelCallAsync(callID, callType);
        }

        public static bool VideoCallCancel()
        {
            return Model_VideoConferenc.VideoCallCancel();
        }

        public static bool AcceptCall()
        {
            return Model_VideoConferenc.AcceptCall();
        }

        public static void Dispose()
        {
            Model_VideoConferenc.Dispose();
        }

        public static void Features_Flash()
        {
            Model_VideoConferencFeatures.Flash();
        }

        public static void Features_Focus(int width, int height, int x, int y)
        {
            Model_VideoConferencFeatures.Focus(width, height, x, y);
        }

        public static void Features_Zoom(double z)
        {
            Model_VideoConferencFeatures.Zoom(z);
        }

        public static void Features_Mark(int width, int height, int sX, int sY, int eX, int eY, int pT, string color, int pWidth)
        {
            Model_VideoConferencFeatures.Mark(width, height, sX, sY, eX, eY, pT, color, pWidth);
        }

        public static void Features_ClearMark()
        {
            Model_VideoConferencFeatures.ClearMark();
        }

        public static void Features_TakePhoto()
        {
            Model_VideoConferencFeatures.TakePhoto();
        }

        public static void Features_LeaveTakingPhoto()
        {
            Model_VideoConferencFeatures.LeaveTakingPhoto();
        }

        public static void Features_SendText(string txt)
        {
            Model_VideoConferencFeatures.SendText(txt);
        }

        public static void Features_SendText(string id, string txt)
        {
            Model_VideoConferencFeatures.SendText(id, txt);
        }

        public static void Features_ClearText()
        {
            Model_VideoConferencFeatures.ClearText();
        }

        public static void Features_VoiceOnly()
        {
            Model_VideoConferencFeatures.VoiceOnly();
        }

        public static void Features_BrightnessModify(int value)
        {
            Model_VideoConferencFeatures.BrightnessModify(value);
        }

        public static void Features_ContrastModify(int value)
        {
            Model_VideoConferencFeatures.ContrastModify(value);
        }

        //public static void Features_SetResolution(Resolution _rsl, BitRate _brate, FrameRate _frate)
        //{
        //    Model_VideoConferencFeatures.SetResolution(_rsl, _brate, _frate);
        //}

        public static void Features_SetResolution(string _rsl)
        {
            Model_VideoConferencFeatures.SetResolution(_rsl);
        }

        public static void Features_SetBitrate(string bit)
        {
            Model_VideoConferencFeatures.SetBitrate(bit);
        }


        //Test

        #region 多人模式

        //public async static void VideoConfCall(string callingID, VideoCallResultHandler result, bool recode = true)
        //{
        //    if (callingID == "")
        //        return;

        //    Configuration.CallingID = callingID;

        //    var _state = await Configuration.GetAccountStatusAsync(callingID);

        //    if (_state == CallStatusType.Online)
        //    {
        //        var WVCC = new WebVideoConfCall(Configuration.CompanyID, Helper.GetTimeStamp().ToString(), Configuration.CallingID, "", RestApiCommonFun.CallBackUrl, recode ? "1" : "0");
        //        WVCC.Call(ConfCallResult);
        //    }

        //    result.Invoke(_state);
        //}

        //private static void ConfCallResult(string response)
        //{
        //    Console.WriteLine("多人会议:" + response);
        //}

        public static string ConfID { get { return Model_VideoConferenc.curCCR?.confid; } }

        public static void VideoConfCall(string[] members, string called, string callmode, string screenmode, string picnum, string title, string rtmppush)
        {
            Model_VideoConferenc.VideoConfCall(members, called, callmode, screenmode, picnum, title, rtmppush);
        }

        public static void VideoConfCtlAdd(string member)
        {
            Model_VideoConferenc.VideoConfCtlAdd(member);
        }

        public static void VideoConfCtlDel(string member)
        {
            Model_VideoConferenc.VideoConfCtlDel(member);
        }

        public static void VideoConfCtlView(string member)
        {
            Model_VideoConferenc.VideoConfCtlView(member);
        }

        //public static void VideoConfMemberStatus(VideoConfMemberStatusHandler memberStatusHandler)
        //{
        //    Model_VideoConferenc.VideoConfMemberStatus(memberStatusHandler);
        //}

        public static void VideoConfCtrlHalt()
        {
            Model_VideoConferenc.VideoConfCtrlHalt();
        }

        #endregion

    }
}
